home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / µSim 1.1 / FabLibsƒ / FabACursors.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-23  |  1.5 KB  |  82 lines  |  [TEXT/CWIE]

  1. #include    "UtilsSys7.h"
  2.  
  3. #include    "FabWmemman.h"
  4. #include    "FabACursors.h"
  5.  
  6. struct fcur {
  7.     short    firstFrameID;
  8.     short    lastFrameID;
  9.     };
  10.  
  11. typedef struct fcur fcur, *fcurPtr, **fcurHandle;
  12.  
  13. static CursHandle *gCursors = nil;
  14. unsigned int    gCursorChanges = 0;
  15. static short    gHowMany = 0;
  16. Boolean        gCanInitCursor = true;
  17.  
  18. #if    !defined(FabNoSegmentDirectives)
  19. #pragma segment Init
  20. #endif
  21.  
  22. OSErr FabLoadCursors(short fCurResID)
  23. {
  24. fcurHandle    cResH;
  25. CursHandle    tempC;
  26. short    first, last, i;
  27. OSErr    err = noErr;
  28.  
  29. if (gCursors == nil) {
  30.     cResH = (fcurHandle)Get1Resource('fCur', fCurResID);
  31.     if (cResH) {
  32.         first = (*cResH)->firstFrameID;
  33.         last = (*cResH)->lastFrameID;
  34.         gHowMany = last - first;
  35.         gCursors = fmalloc((gHowMany + 1) * sizeof(CursHandle));
  36.         for (i = first; i <= last; i++) {
  37.     //    for (i = 0; i <= gHowMany; i++)
  38.             tempC = GetCursor(i);
  39.     //        tempC = GetCursor(i + first);
  40.             if (tempC == nil) {
  41.                 FabFreeCursors();
  42.                 break;
  43.                 }
  44.             gCursors[i - first] = tempC;
  45.     //        gCursors[i] = tempC;
  46.             }
  47.         }
  48.     else
  49.         err = ResError();
  50.     }
  51. return err;
  52. }
  53.  
  54. #if    !defined(FabNoSegmentDirectives)
  55. #pragma segment Main
  56. #endif
  57.  
  58. void FabRotateCursor(void)
  59. {
  60. static UInt32    oldtick = 0;
  61. static int    indx = 0;
  62. UInt32 tick = TickCount();
  63.  
  64. if ((tick - oldtick) > 30UL /*&& LMGetCrsrBusy() == false*/) {
  65.     indx++;
  66.     indx &= gHowMany;
  67.     SetCursor(*gCursors[indx]);
  68.     gCursorChanges++;
  69.     oldtick = tick;
  70.     gCanInitCursor = false;
  71.     }
  72. }
  73.  
  74. void FabFreeCursors(void)
  75. {
  76. if (gCursors) {
  77.     SAFEDESTROY(ffree, CursHandle *, gCursors, CursHandle *)
  78.     gHowMany = 0;
  79.     }
  80. }
  81.  
  82.